package org.scratchcrew.domain.dao;

import java.util.HashMap;
import java.util.Map;

import org.scratchcrew.domain.BoardData;
import org.springframework.dao.support.DataAccessUtils;
import org.springframework.stereotype.Repository;

@Repository(value = "boardDataDao")
public class BoardDataDaoImpl extends EntityDaoSupport<BoardData> implements
		BoardDataDao {
	public BoardDataDaoImpl() {
		super(BoardData.class);
	}

	@Override
	public BoardData findByBoardId(Long boardId) {
		Map<String, Object> parameters = new HashMap<String, Object>();
		parameters.put("boardId", boardId);
		BoardData result = (BoardData) DataAccessUtils
				.uniqueResult(getJpaTemplate().findByNamedParams(
						"select bd from BoardData bd where bd.board.id = :boardId",
						parameters));
		return result;
	}
}
